﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Reddit
{
    namespace JsonParser
    {
        public class ArrayDataContractSurrogate : IDataContractSurrogate
        {
            private Type[] _types;
            private Type _baseType;
            int _pos = 0;

            public ArrayDataContractSurrogate(Type baseType, Type[] types)
            {
                this._baseType = baseType;
                this._types = types;
            }
            #region IDataContractSurrogate Members

            public object GetCustomDataToExport(Type clrType, Type dataContractType)
            {
                throw new NotImplementedException();
            }

            public object GetCustomDataToExport(System.Reflection.MemberInfo memberInfo, Type dataContractType)
            {
                throw new NotImplementedException();
            }

            public Type GetDataContractType(Type type)
            {
                if (type.Equals(this._baseType))
                {
                    if (this._pos >= this._types.Length)
                    {
                        throw new JsonParseException("Too many array elements");
                    }
                    return this._types[this._pos++];
                }
                return type;
            }

            public object GetDeserializedObject(object obj, Type targetType)
            {
                return obj;
            }

            public void GetKnownCustomDataTypes(System.Collections.ObjectModel.Collection<Type> customDataTypes)
            {
                throw new NotImplementedException();
            }

            public object GetObjectToSerialize(object obj, Type targetType)
            {
                throw new NotImplementedException();
            }

            public Type GetReferencedTypeOnImport(string typeName, string typeNamespace, object customData)
            {
                throw new NotImplementedException();
            }

            public System.CodeDom.CodeTypeDeclaration ProcessImportedType(System.CodeDom.CodeTypeDeclaration typeDeclaration, System.CodeDom.CodeCompileUnit compileUnit)
            {
                throw new NotImplementedException();
            }

            #endregion
        }
    }
}
